package com.briup.cms.web.controller;

import com.briup.cms.bean.Config;
import com.briup.cms.service.IConfigService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Api(description = "配置管理相关接口")
@RestController
@RequestMapping("config")
public class ConfigController{
    @Autowired
    private IConfigService configService;

    @ApiOperation(value = "查询所有")
    @GetMapping("findAll")
    public Message findAll(){
        List<Config>  list= configService.findAll();
        return MessageUtil.success(list);
    }
    @ApiOperation(value = "保存或更新")
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Config config){
        configService.saveOrUpdate(config);
        return MessageUtil.success("操作成功");
    }
    @ApiOperation(value="删除")
    @GetMapping("deleteById")
    public Message deleteById(long id){
        configService.deleteById(id);
        return MessageUtil.success("操作成功");
    }
}
